package com.son.hotel.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private String code;
    private String msg;
    private ErrorCode errorCode;
    private T data;

    public static <T> Result<T> success(String code,T data){
        Result<T> result = new Result<>();
        result.code = code;
        result.data = data;
        return result;
    }

    public static <T> Result<T> success(String code,String msg){
        Result<T> result = new Result<>();
        result.code = code;
        result.msg = msg;
        return result;
    }

    public static <T> Result<T> success(String code,ErrorCode errorCode ,T data){
        Result<T> result = new Result<>();
        result.code = code;
        result.errorCode = errorCode;
        result.data = data;
        return result;
    }

    public static <T> Result<T> success(ErrorCode errorCode){
        Result<T> result = new Result<>();
        result.errorCode = errorCode;
        return result;
    }

    public static <T> Result<T> success(ErrorCode errorCode,T data){
        Result<T> result = new Result<>();
        result.errorCode = errorCode;
        result.data = data;
        return result;
    }

    public static <T> Result<T> error(String code,String msg){
        Result<T> result = new Result<>();
        result.code = code;
        result.msg = msg;
        return result;
    }

    public static <T> Result<T> error(ErrorCode errorCode){
        Result<T> result = new Result<>();
        result.errorCode = errorCode;
        return result;
    }
}
